<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>EOS.IO: Memory C API</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="eos-logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">EOS.IO
   &#160;<span id="projectnumber">DAWN1.1.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li class="current"><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Memory C API<div class="ingroups"><a class="el" href="group__contractdev.html">How To Write Contracts</a> &raquo; <a class="el" href="group__memoryapi.html">Memory API</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p>Defines common memory functions.  
<a href="#details">More...</a></p>
<div class="dynheader">
Collaboration diagram for Memory C API:</div>
<div class="dyncontent">
<center><table><tr><td><img src="group__memorycapi.png" border="0" alt="" usemap="#group____memorycapi"/>
<map name="group____memorycapi" id="group____memorycapi">
<area shape="rect" id="node1" href="group__memoryapi.html" title="Defines common memory functions. " alt="" coords="5,5,100,32"/>
</map>
</td></tr></table></center>
</div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga87ed00a8f774a9d36d650b80a36ad932"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__memorycapi.html#ga87ed00a8f774a9d36d650b80a36ad932">sbrk</a> (<a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a> num_bytes)</td></tr>
<tr class="memdesc:ga87ed00a8f774a9d36d650b80a36ad932"><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocate page memory.  <a href="#ga87ed00a8f774a9d36d650b80a36ad932">More...</a><br /></td></tr>
<tr class="separator:ga87ed00a8f774a9d36d650b80a36ad932"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga59ed1449718a3c27f7622cb3efb845af"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__memorycapi.html#ga59ed1449718a3c27f7622cb3efb845af">memcpy</a> (void *destination, const void *source, <a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a> num)</td></tr>
<tr class="memdesc:ga59ed1449718a3c27f7622cb3efb845af"><td class="mdescLeft">&#160;</td><td class="mdescRight">Copy a block of memory from source to destination.  <a href="#ga59ed1449718a3c27f7622cb3efb845af">More...</a><br /></td></tr>
<tr class="separator:ga59ed1449718a3c27f7622cb3efb845af"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga174f86fdde222a278e5524a8aea63da9"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__types.html#ga0d2e949ab6a1bb62f1b295cc79bc1f60">int32_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__memorycapi.html#ga174f86fdde222a278e5524a8aea63da9">memcmp</a> (void *ptr1, const void *ptr2, <a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a> num)</td></tr>
<tr class="memdesc:ga174f86fdde222a278e5524a8aea63da9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Copy a block of memory from source to destination.  <a href="#ga174f86fdde222a278e5524a8aea63da9">More...</a><br /></td></tr>
<tr class="separator:ga174f86fdde222a278e5524a8aea63da9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad8eef9133e11fe77cd34792771f81761"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__memorycapi.html#gad8eef9133e11fe77cd34792771f81761">memset</a> (void *ptr, <a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a> value, <a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a> num)</td></tr>
<tr class="memdesc:gad8eef9133e11fe77cd34792771f81761"><td class="mdescLeft">&#160;</td><td class="mdescRight">Fill a block of memory with the provided value.  <a href="#gad8eef9133e11fe77cd34792771f81761">More...</a><br /></td></tr>
<tr class="separator:gad8eef9133e11fe77cd34792771f81761"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="ga174f86fdde222a278e5524a8aea63da9"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__types.html#ga0d2e949ab6a1bb62f1b295cc79bc1f60">int32_t</a> memcmp </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>ptr1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>ptr2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>&#160;</td>
          <td class="paramname"><em>num</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Compare block of memory from source to destination. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ptr1</td><td>Pointer to first data to compare </td></tr>
    <tr><td class="paramname">ptr2</td><td>Pointer to second data to compare </td></tr>
    <tr><td class="paramname">num</td><td>Number of bytes to compare.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the destination pointer </dd></dl>

</div>
</div>
<a class="anchor" id="ga59ed1449718a3c27f7622cb3efb845af"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* memcpy </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>destination</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>source</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>&#160;</td>
          <td class="paramname"><em>num</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Copy a block of memory from source to destination. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">destination</td><td>Pointer to the destination to copy to. </td></tr>
    <tr><td class="paramname">source</td><td>Pointer to the source for copy from. </td></tr>
    <tr><td class="paramname">num</td><td>Number of bytes to copy.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the destination pointer</dd></dl>
<p>Example: </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;char dest[6] = { 0 };</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;char source[6] = { &#39;H&#39;, &#39;e&#39;, &#39;l&#39;, &#39;l&#39;, &#39;o&#39;, &#39;\0&#39; };</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;memcpy(dest, source, 6 * sizeof(char));</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;prints(dest); // Output: Hello</div></div><!-- fragment --> 
</div>
</div>
<a class="anchor" id="gad8eef9133e11fe77cd34792771f81761"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* memset </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>ptr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>&#160;</td>
          <td class="paramname"><em>value</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>&#160;</td>
          <td class="paramname"><em>num</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Fill block of memory. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ptr</td><td>Pointer to memory to fill. </td></tr>
    <tr><td class="paramname">value</td><td>Value to set (it is passed as an int but converted to unsigned char). </td></tr>
    <tr><td class="paramname">num</td><td>Number of bytes to be set to the value.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the destination pointer</dd></dl>
<p>Example: </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;char ptr[6] = { &#39;H&#39;, &#39;e&#39;, &#39;l&#39;, &#39;l&#39;, &#39;o&#39;, &#39;\0&#39; };</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;memset(ptr, &#39;y&#39;, 6 * sizeof(char));</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;prints(ptr); // Output: yyyyyy</div></div><!-- fragment --> 
</div>
</div>
<a class="anchor" id="ga87ed00a8f774a9d36d650b80a36ad932"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* sbrk </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>&#160;</td>
          <td class="paramname"><em>num_bytes</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Allocate page(s) of memory to accommodate the requested number of bytes. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">num_bytes</td><td>Number of bytes to add.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void pointer to the previous end of allocated bytes</dd></dl>
<p>Example: </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;// allocate a whole new page, the returned offset is the pointer to the</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;// newly allocated page</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;char* new_page = static_cast&lt;char*&gt;(sbrk(65536));</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;memset(new_page, 0, 65536);</div></div><!-- fragment --> 
</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.11
</small></address>
</body>
</html>
